# -*- coding: utf-8 -*-
import scrapy
from douban_book.items import DoubanBookItem

class BookSpider(scrapy.Spider):
    name = 'book'
    allowed_domains = ['book.douban.com']
    start_urls = ['https://book.douban.com/top250']

    def parse(self, response):
        book_list = response.xpath("//div[@class='article']/div[@class='indent']//table")
        for book in book_list:
            book_td = book.xpath("//tr[@class='item']/td")
            book_top = book.xpath("//tr[@class='item']/td[@class='top']")
            print(book_td.extract())
            print(book_top.extract())

            # douban_book = DoubanBookItem()
            # douban_book['book_name'] = book_top.xpath("//div/a").extract()
            # douban_book['book_image'] = book_td[0].xpath("//a/img/@scr").extract()
            # douban_book['book_author'] = book_top.xpath("//p[@class='pl']/text()").extract()
            # # douban_book['book_price'] = book_top.xpath('')
            # douban_book['book_grade'] = book_top.xpath("//div[@class='star clearfix']/span[@class='rating_nums]/text()").extract()
            # douban_book['book_describe'] = book_top.xpath("//p[@class='quote']/span[@class='inq']/text()").extract()
            # print(douban_book)